"""paper_table_add_conference_id

Revision ID: 450f0e1f6634
Revises: 0aa1fd6c1c28
Create Date: 2025-11-19 11:58:03.270203

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '450f0e1f6634'
down_revision: Union[str, Sequence[str], None] = '0aa1fd6c1c28'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('author', schema=None) as batch_op:
        batch_op.add_column(sa.Column('conference_id', sa.Integer(), nullable=False))

    with op.batch_alter_table('paper', schema=None) as batch_op:
        batch_op.alter_column('conference_id',
               existing_type=sa.INTEGER(),
               nullable=False)

    with op.batch_alter_table('paper_author_relation', schema=None) as batch_op:
        batch_op.alter_column('paper_id',
               existing_type=sa.INTEGER(),
               nullable=False)
        batch_op.alter_column('author_id',
               existing_type=sa.INTEGER(),
               nullable=False)

    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('paper_author_relation', schema=None) as batch_op:
        batch_op.alter_column('author_id',
               existing_type=sa.INTEGER(),
               nullable=True)
        batch_op.alter_column('paper_id',
               existing_type=sa.INTEGER(),
               nullable=True)

    with op.batch_alter_table('paper', schema=None) as batch_op:
        batch_op.alter_column('conference_id',
               existing_type=sa.INTEGER(),
               nullable=True)

    with op.batch_alter_table('author', schema=None) as batch_op:
        batch_op.drop_column('conference_id')

    # ### end Alembic commands ###
